var offset=0;
$(document).ready(function()
{
	$("#discountStart").datepicker();
	$("#discountStop").datepicker();
	
	if($('#fckTextAreaBasic').length > 0)
	{
		var oFCKeditor = new FCKeditor( 'fckTextAreaBasic' ) ;
		oFCKeditor.BasePath = "./public/js/jplugins/fckeditor/" ;
		oFCKeditor.Height = 200;
		oFCKeditor.ToolbarSet = 'Basic';
		oFCKeditor.ReplaceTextarea() ;
	}
	
	if($('#fckTextArea').length > 0)
	{
		var oFCKeditor = new FCKeditor( 'fckTextArea' ) ;
		oFCKeditor.BasePath = "./public/js/jplugins/fckeditor/" ;
		oFCKeditor.Height = 400;
		oFCKeditor.Width = 600;
		oFCKeditor.ReplaceTextarea() ;
	}
	
	$('#addKeywords').click(function() {  
     return !$('#keywords_unsigned option:selected').remove().appendTo('#keywords_used');  
    });  

    $('#removeKeywords').click(function() {  
		
     return !$('#keywords_used option:selected').remove().appendTo('#keywords_unsigned');  
    });
});

function showBruttoPrice()
{
//	alert($('#netto_price').val() * 1.22 );
	$('#brutto_price').val($('#netto_price').val() * 1.22) ;
}

function hideOrShow(idDisplayedElemant)
{
//	alert('asdfas');
	if($('#'+idDisplayedElemant).attr("class") == "d-block")
	{
		$('#'+idDisplayedElemant).removeClass('d-block');
		$('#'+idDisplayedElemant).addClass('d-none');
	}
	else
	{
		$('#'+idDisplayedElemant).removeClass('d-none');
		$('#'+idDisplayedElemant).addClass('d-block');
	}
}

function hideOrShowConfirmation(idDisplayedElemant)
{
//	alert('asdfas');
	if($('#'+idDisplayedElemant).attr("class") == "d-table-row")
	{
		$('#'+idDisplayedElemant).removeClass('d-table-row');
		$('#'+idDisplayedElemant).addClass('d-none');
	}
	else
	{
		$('#'+idDisplayedElemant).removeClass('d-none');
		$('#'+idDisplayedElemant).addClass('d-table-row');
	}
}

function showDialogWindow()
{
	
//	var cssObj = {
//        'display' : 'block'
//      }
//		
//		$('#addCategory').children('#rem').remove();
//		$('#addCategory').
	$.ajax({
		type: "POST",			
		url: 'ajax.php?mod=back&view=ajaxCategories&act=getAllCategories',
		data: 
		{
			test: data
		},		   
		dataType: 'json',
		beforeSend: function()
		{
			
		},
		success: function(response)
		{			
			$().click(function(e)
			{
				$('#dialog').dialog( 'close');
				$('#dialog').remove();
				$('#addCategory').append('<div id="dialog" title="Okienko dialogowe">'+response[0][1]+'</div>');
				
		    	$('#dialog').dialog(
				{ 	
					draggable: true , 
					resizable: true,
					position: [e.pageX,e.pageY],
					close: function(event, ui) 
					{
						$('#addCategory').children('#dialog').remove();
					}
				});
		   	});				 
		},
		error: function(er)
		{
			alert('error');
		}
	});	

	
	
}

function addKeyword()
{
//	selectedItems = $('#allKeywodrs').val();
//	for(var i=0; i<selectedItems.length; i++)
//	{
//		alert(selectedItems[i].id);
//		$('#selectedKeywodrs').append('<option value="'+selectedItems[i]+'">name</option>');
//	}
	
}

